package com.milan.analysis.common.extend;


import com.alibaba.fastjson.JSON;

import java.beans.PropertyEditorSupport;


public class JsonPropertyEditorSupport extends PropertyEditorSupport {
    private Class<?> clazz;

    /**
     * @param clazz Java ????
     */
    public JsonPropertyEditorSupport(Class<?> clazz) {
        this.clazz = clazz;
    }

    @Override
    public String getAsText() {
        return JSON.toJSONString(getValue());
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        setValue(JSON.parseObject(text, clazz));
    }
}